#!/usr/bin/python
import unittest
from StringIO import StringIO
import sys
import os

# Import app modules
from uya.configmod_web import misc

class TestMiscLibrary(unittest.TestCase):        
    def setUp(self):
        pass

    def test_struct(self):
        struct = misc.Struct(var1=1, var2=2)
        self.assertEqual(1, struct.var1)
        self.assertEqual(2, struct.var2)
        self.assertRaises(AttributeError, lambda: struct.var3)
        struct.var1 = 11
        self.assertEqual(11, struct.var1)

    def test_all(self):
        self.assertTrue(misc.all([1, 2, 3]))
        self.assertFalse(misc.all([1, 2, "", 3])) 

    def test_any(self):
        self.assertTrue(misc.any([0, 1, 0]))
        self.assertFalse(misc.any([0, "", None])) 

def suite():
    return unittest.TestLoader().loadTestsFromTestCase(TestMiscLibrary)
         
if __name__ == '__main__':
    unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
